function getTimeParam(taskStatType) {
    const today = new Date();
    const todayEnd = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 23, 59, 59);

    // 格式化日期为 "YYYY-MM-DD HH:mm:ss"
    const formatDate = (date) => {
        const pad = (num) => num.toString().padStart(2, '0');
        return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ` +
            `${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`;
    };

    let startTime;

    switch (taskStatType) {
        case "2": // 年统计
            startTime = new Date(today.getFullYear(), 0, 1, 0, 0, 0);
            break;
        case "3": // 月统计
            startTime = new Date(today.getFullYear(), today.getMonth(), 1, 0, 0, 0);
            break;
        case "4": // 周统计
            const mondayOffset = today.getDay() === 0 ? 6 : today.getDay() - 1;
            startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate() - mondayOffset, 0, 0, 0);
            break;
        default: // 日统计
            startTime = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);
    }

    return {
        startTime: formatDate(startTime),
        endTime: formatDate(todayEnd)
    };
}


console.log(getTimeParam("2"));
// 输出: { startTime: "2025-01-01 00:00:00", endTime: "2025-05-20 23:59:59" }

console.log(getTimeParam("3"));
// 输出: { startTime: "2025-05-01 00:00:00", endTime: "2025-05-20 23:59:59" }

console.log(getTimeParam("4"));
// 输出: { startTime: "2025-05-19 00:00:00", endTime: "2025-05-20 23:59:59" } (假设 5月19日是周一)

console.log(getTimeParam("1"));
// 输出: { startTime: "2025-05-20 00:00:00", endTime: "2025-05-20 23:59:59" }
